import 'package:demo/widget/draggable_window.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DragExample extends StatefulWidget {
  const DragExample({Key? key}) : super(key: key);

  @override
  DragExampleState createState() => DragExampleState();
}

class DragExampleState extends State<DragExample> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("拖拽容器"),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: '首页',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.category),
            label: '分类',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.settings),
            label: '设置',
          ),
        ],
      ),
      body: Stack(
        fit: StackFit.expand,
        children: [
          DraggableWindowWidget(
            initOffset: Offset(50, 60),
            securityInsets: const EdgeInsets.only(top: 15, bottom: 14),
            headerHeight: 56 + MediaQuery.of(context).padding.top,
            bottomHeight: 56 + MediaQuery.of(context).padding.bottom,
            child: Container(
              color: Colors.orange,
              width: 65,
              height: 55,
              alignment: Alignment.center,
              child: Text(
                "默认逻辑",
                style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
              ),
            ),
          ),
          DraggableWindowWidget(
            initOffset: Offset(150, 180),
            child: Container(
              color: Colors.blueAccent,
              width: 75,
              height: 55,
              alignment: Alignment.center,
              child: Text(
                "自定义逻辑",
                style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
